package collections;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class CollectionsDemo {

    public static void main(String[] args) {
        String[] fruits = {"banana","grape","apple","pear","apple","watermelon"};
        List list = Arrays.asList(fruits);

        Collections.sort(list);
        System.out.println(list);
        Collections.reverse(list);
        System.out.println(list);
        Collections.shuffle(list); //随机打乱次序。
        System.out.println(list);

        Collections.rotate(list,1);
        System.out.println(list);

        System.out.println(Collections.min(list));
        System.out.println(Collections.max(list));
        //注意：使用二分查找算法必须先排序
        Collections.sort(list);
        System.out.println(Collections.binarySearch(list, "pear"));
        Collections.fill(list,"水果");
        System.out.println(list);
    }
}
